package org.bigjava.mapper.impl;

import org.bigjava.bean.Admin;
import org.bigjava.bean.User;
import org.bigjava.mapper.UserDao;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("userDao")
public class UserDaoImpl implements UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<Admin> quan() {
        System.out.println("全查");
        String sql = "select * from admin";
        RowMapper<Admin> rm = new BeanPropertyRowMapper<>(Admin.class);
        return jdbcTemplate.query(sql,rm);
    }

    public List<User> zon(){
        String sql = "select * from user";
        RowMapper<User> row = new BeanPropertyRowMapper<>(User.class);
        return jdbcTemplate.query(sql,row);
    }
}
